{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3c98bde2",
   "metadata": {},
   "source": [
    "* 学习方法 \n",
    "> 1. listname.Tab键 查看所有方法名称\n",
    "> 2. help(listname.function) 查看其中一个方法的具体操作内容\n",
    "\n",
    "> 课后练习（做一个表格，总结列表的方法）：\n",
    "\n",
    "\n",
    "| 列表方法      | Description | example      |备注|\n",
    "| ----------- | ----------- |----------- |----------- |\n",
    "| append()      |  增加元素，增加在列表的末尾      | names.append(\"zhichao\")，  ['Mike', 'Marry', 'Jan', 'Jack', 'zhichao'] |   |\n",
    "|  count() |  统计某个元素在列表中出现的次数 |  names.count(\"zhichao\"),1 |   |\n",
    "|  extend() |  在列表末尾一次性追加另一个序列中的多个值（用新列表拓展原来的列表） |  ma = [\"zi\", \"jie\"],names.append(ma), ,names ['Mike', 'marry', 'jan', 'jack', 'zhichao', ['zi', 'jie']]|   |\n",
    "|  index() |  从列表中找出某个值第一个匹配项的索引个位置 |  names.index(\"zhichao\"),4 |   |\n",
    "|  insert() |  将对象插入列表 |  names.insert(3,'zijie'),names ['Mike', 'marry', 'jan', 'zijie', 'jack','zhichao'] |   |\n",
    "|  pop() |  移除列表中的一个元素（默认最后一个元素），并返回该元素的值 |  names.pop(0) 'Mike',names  ['marry','jan', 'zijie', 'jack', 'zhichao'] |   |\n",
    "|  remove() |  移除列表中某个值的第一个匹配项 |  names.remove(\"marry\"),names  ['jan', 'zijie', 'jack','zhichao'] |   |\n",
    "|  reverse() |  反向列表中元素 |  names.reverse(),names ['zhichao', 'jack', 'zijie', 'jan'] |   |\n",
    "|  sort() |  对原列表进行排序 |  names.sort(),names ['jack', 'jan', 'zhichao', 'zijie'] |   |\n",
    "|  clear() |  清空列表 |  names.clear(),names [] |   |\n",
    "|  copy() |  复制列表 |  names.copy(),['jack', 'jan', 'zhichao', 'zijie'] |   |\n",
    "|   |   |   |   |\n",
    "| Paragraph   | Text        |   |   |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "94e0ecc1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "61ca4c16",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "fc6fe9f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'marry', 'jan', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "9038e272",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(3,'zijie')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "8d1d21f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'marry', 'jan', 'zijie', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "3ba1f7c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mike'"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "82c7ecaa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['marry', 'jan', 'zijie', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "9cdc9682",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.remove(\"marry\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "468a4c61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jan', 'zijie', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "80bd4092",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "32b1a0c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['zhichao', 'jack', 'zijie', 'jan']"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "357887de",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "cf3c418a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'jan', 'zhichao', 'zijie']"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "d1bf11d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'jan', 'zhichao', 'zijie']"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "16839491",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "3c8d3530",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ab4efa08",
   "metadata": {},
   "outputs": [],
   "source": [
    "ma = [\"zi\", \"jie\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "697b2e28",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(ma)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b49f8ed5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'marry', 'jan', 'jack', 'zhichao', ['zi', 'jie']]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b9735af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "vscode": {
   "interpreter": {
    "hash": "52f15d3cfa1b6a9af5423e55be89f2d13263845687b717213655097fb5509b98"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
